<?php
/**
 * The MIT License (MIT)
 * Copyright © 2021 Walkline Wang (https://walkline.wang)
 * https://gitee.com/walkline/online-update-manager
 */	

	class API_Exception	{
		public function get_response_object($error_code) {
			$error_msg = "";
			$return_object = array();

			switch ($error_code) {
				case 1001:
					$error_msg = "未知的接口";
					break;
				case 1002:
					$error_msg = "非法用户访问";
					break;
				case 1003:
					$error_msg = "非法用户访问，用户不存在";
					break;
				case 2000:
					$error_msg = "username 为空";
					break;
				case 2001:
					$error_msg = "password 为空";
					break;
				case 2002:
					$error_msg = "用户名密码错误";
					break;
				case 2003:
					$error_msg = "package_name 为空";
					break;
				case 2004:
					$error_msg = "package_name 已存在";
					break;
				case 2005:
					$error_msg = "upload_files 为空";
					break;
				case 2006:
					$error_msg = "app_version 为空";
					break;
				case 2007:
					$error_msg = "app_note 为空";
					break;
				case 2008:
					$error_msg = "is_apk 为空";
					break;
				case 2009:
					$error_msg = "is_wgt 为空";
					break;
				case 2010:
					$error_msg = "is_force_update 为空";
					break;
				case 2011:
					$error_msg = "file is not upload via post";
					break;
				case 2012:
					$error_msg = "make upload folder failed";
					break;
				case 2013:
					$error_msg = "move upload_file to folder failed";
					break;
				case 2014:
					$error_msg = "package_name 记录为空";
					break;
				case 2015:
					$error_msg = "is_apk, is_wgt 不能同时为 false";
					break;
				case 2016:
					$error_msg = "params 为空";
					break;
				case 2017:
					$error_msg = "app 文件已存在";
					break;
				case 2018:
					$error_msg = "更新信息有误，请联系管理员";
					break;
				case 2019:
					$error_msg = "资源文件不存在，请联系管理员";
					break;
				case 2020:
					$error_msg = "filename 为空";
					break;
				case 2021:
					$error_msg = "sub_folder 为空";
					break;
				case 2022:
					$error_msg = "append_data 为空";
					break;
				case 2023:
					$error_msg = "id 为空";
					break;
				case 2024:
					$error_msg = "size 为空";
					break;
				case 2025:
					$error_msg = "date 为空";
					break;
				case 2026:
					$error_msg = "include_file 类型错误";
					break;
				case 2027:
					$error_msg = "记录不存在";
					break;
			}

			$return_object = (object) array(
				"error_code" => $error_code,
				"error_msg" => $error_msg
			);

			return $return_object;
		}
	}
?>